package com.github.browep.bat.activities;

import android.app.Activity;
import android.content.Context;
import android.test.ActivityInstrumentationTestCase2;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import com.github.browep.bat.R;

import java.util.List;

import static com.github.browep.bat.util.UiUtilities.findAllByTag;

//import com.github.browep.bat.R;

/**
 * Created by IntelliJ IDEA.
 * User: paul
 * Date: 8/28/11
 * Time: 1:36 PM
 * To change this template use File | Settings | File Templates.
 */
public class TestUiUtilities extends ActivityInstrumentationTestCase2<SterileActivity> {

    private Activity activity;
    private ViewGroup contentRoot;
    private View inflatedView;

    public TestUiUtilities() {
        super("com.github.browep.bat", SterileActivity.class);
    }

    @Override
    public void setUp() throws Exception {
        super.setUp();
        activity = getActivity();
        contentRoot = (ViewGroup) getActivity().findViewById(android.R.id.content).getRootView();

        LayoutInflater inflater = (LayoutInflater) activity.getSystemService
                (Context.LAYOUT_INFLATER_SERVICE);
        inflatedView = inflater.inflate(R.layout.home, new LinearLayout(activity), true);
    }

    public void testFindAllByTag() throws Exception {
        assertNotNull(activity);

        List<View> views = findAllByTag((ViewGroup) inflatedView, "homeTile");
        assertEquals(4, views.size());
        for(View view : views)
            assertEquals(Button.class,view.getClass());



    }
}
